<!DOCTYPE html>
<html lang="en">
<head>
    <title>考勤公司级别</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style>
        .bgOne {
            color: black;
        }

        .bgTwo {
            color: red;
        }

        .bgThree {
            color: #9d9d9d;
        }
        .nav-tabs-custom {
            padding: 10px;
            margin-bottom: 0;
            box-shadow: none;
            position: relative;
            overflow: hidden;
        }
        .moduleName {
            float: left;
            height: 27px;
            line-height: 27px;
            font-size: 22px;
            width: 100px;
            text-align: center;
        }
        .lineOne{
            text-align: left;
        }
        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        .infoReport {
            width: 160px;
            margin: 0 auto;
            text-align: left;
            margin-top: 10px;
        }

        .infoReport div {
            margin: 10px 0;
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <div class="nav-tabs-custom oaReportNav">
        <!-- Tabs within a box -->
        <div class="moduleName">微信转发</div>
        <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;" v-cloak>
            <li :class="isActive(today)?'active':''"  @click="refreshData('wechat','get_wechatCompany',today)"><a href="#sales-chart" data-toggle="tab">今日</a></li>
            <li :class="isActive(yesterday)?'active':''"  @click="refreshData('wechat','get_wechatCompany',yesterday)"><a href="#sales-chart" data-toggle="tab">昨日</a></li>
            <!--<li :class="isActive(thisWeek)?'active':''"  @click="refreshData('wechat','get_wechatCompany',thisWeek)"><a href="#sales-chart" data-toggle="tab">本周</a></li>-->
            <li :class="isActive(thisMonth)?'active':''" @click="refreshData('wechat','get_wechatCompany',thisMonth)"> <a href="#sales-chart" data-toggle="tab">本月</a></li>
            <li :class="isActive(item.time)?'active':''" v-for="(item,i) in tab"  @click="refreshData('wechat','get_wechatCompany',item.time)"><a href="#sales-chart" data-toggle="tab">{{i==0?"上月":item.str}}</a></li>
        </ul>
    </div>
    <div style="padding: 0 10px;background: #fff;" id="signInCompany">
        <div  class="mScrollBox" id="wechatCompany" style="width:100%;float:left;">
            <table class="table text-center table-width">
                <thead>
                <tr>
                    <!--<th style="width:5%;">序号</th>-->
                    <th style="width: 10%" class="tableTitle">岗位</th>
                    <th style="width: 8%;" class="tableTitle">姓名</th>
                    <th style="width: 8%;" class="tableTitle">应转发</th>
                    <th style="width:8%;" class="tableTitle">已转发</th>
                    <th style="width: 8%;" class="tableTitle">未转发</th>
                    <th style="width: 8%;" class="tableTitle">好友数</th>
                    <th style="width: 45%" class="tableTitle">区域</th>
                </tr>
                </thead>
                <tbody>
                <template v-if="wechat.list.length>0">
                    <tr v-for="(item,i) in wechat.list">
                        <!--<td>{{i+1}}</td>-->
                        <td :rowspan="item.roleNamespan" :class="{hidden: item.roleNamedis}" style="border-right: 1px solid #cbcbcd;">{{item.roleName}}</td>
                        <td style="color:#169BD5;cursor: pointer;" @click="openWechatPersonal(item)" class="openUserBox" :attrid="item.userId">{{item.userName}}</td>
                        <td>{{item.forward}}</td>
                        <td>{{item.finishForward}}</td>
                        <td style="color: red;">{{item.noForward}}</td>
                        <td>{{item.contacts?item.contacts:"-"}}</td>
                        <td class="lineOne">
                            <span>{{item.regionName}}</span>
                        </td>
                    </tr>
                    <tr>
                        <td>合计</td>
                        <td>-</td>
                        <td>{{wechat.reportShare.forward}}</td>
                        <td>{{wechat.reportShare.finishForward}}</td>
                        <td>{{wechat.reportShare.noForward}}</td>
                        <td>{{wechat.reportShare.contacts}}</td>
                        <td>-</td>
                    </tr>
                </template>
                <template v-else>
                    <tr><td colspan="7">暂无数据~</td></tr>
                </template>
                </tbody>
            </table>
        </div>
        <!--<div style="width: 20%;float:right;">-->
            <!--<div class="infoReport">-->
                <!--<div>应转发(总)：{{wechat.reportShare.forward}}</div>-->
                <!--<div>已转发(总)：{{wechat.reportShare.finishForward}}</div>-->
                <!--<div>未转发(总)：{{wechat.reportShare.noForward}}</div>-->
                <!--<div>好友数(总)：{{wechat.reportShare.contacts}}</div>-->
            <!--</div>-->
        <!--</div>-->
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script>
</script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            companyId: $.wyui.page.urlParams.companyId?$.wyui.page.urlParams.companyId:getCurrentUser().companyId,
            yesterday:new Date(new Date()-24*60*60*1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),//今天
            hour:new Date().getHours(),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            tab:[],
            wechat: {
                time: $.wyui.page.urlParams.dateTime?$.wyui.page.urlParams.dateTime:new Date().Format("yyyy-MM-dd"),
                list: [],
                reportShare: {Forward:0,FinishForward:0,NoForward:0}
            },userBox:{
                name:'',
                tel:'',
                roleName:'',
                entryDate:'',
                dayNumber:''
            }
        },
        methods: {
            //获取tab
            getTab: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");
                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.tab.push(that.insert_flg(dateTime, "-", "4"))
                }
                console.log(that.tab)
            },
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            //格式化日期
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                var st1=newstr.substr(2,2);
                var st2=newstr.substr(5,2);
                var newstr3=st2+"/"+st1;
                var obj={str:newstr,time:newstr};
                return obj;
            },
            //tab中点击日期刷新对应数据
            refreshData:function (dataType,fun,time) {
                var that=this;
                that[dataType].time=time;
                that[fun]();
            },
            isActive:function (item) {
                var that=this;
                if(that.wechat.time==item){
                    return true;
                }
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            //获取费用报表-区域经理
            get_wechatCompany:function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.wechatShareRegion.getForDepartBycompanyId, {
                    "companyId": that.companyId,
                    "dateTime": that.wechat.time
                }, function (data) {
                    var data=trimRN2(data);
                    that.wechat.list = that.tablesMergeCell(data);
                },false,"#wechatCompany");
                $.wyui.postMethod(urlConfig.report.wechatShareRegion.getWechatTotalforDepartByCompanyId, {
                    "companyId": that.companyId,
                    "dateTime": that.wechat.time
                }, function (data) {
                    var data=trimRN2(data);
                    that.wechat.reportShare = data;
                });
            },
            openWechatPersonal:function(item){
                var that=this;
                top.closeTabByPageId("openWechatPersonal");
                top.addTabs({
                    id: "openWechatPersonal",
                    title: item.userName+"详情",
                    close: true,
                    url: '/reportForm/wechat/wechatPersonal.html?userId='+item.userId+"&dateTime="+that.wechat.time
                });
            },
        },
        mounted: function () {
            var that = this;
            //1.获取前5个月的tab数据
            this.getTab();
            this.get_wechatCompany();
        }
    });
</script>

</body>
</html>